<template>
  <div class="app-container">
    <el-container class="full-container">
      <!-- 顶部导航栏 -->
      <el-header class="header">
        <div class="header-content">
          <div class="header-left">
            <span class="header-title">系统导航栏</span>
          </div>
          <div class="header-right">
            <el-button type="text" class="header-btn">用户中心</el-button>
            <el-button type="text" class="header-btn">退出</el-button>
          </div>
        </div>
      </el-header>

      <el-container class="main-container">
        <!-- 左侧导航栏 -->
        <el-aside class="sidebar">
          <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
            :collapse="false"
          >
            <el-sub-menu index="1">
              <template #title>
                <el-icon><location /></el-icon>
                <span>功能菜单</span>
              </template>
              <el-menu-item-group title="功能组一">
                <el-menu-item index="1-1">功能一</el-menu-item>
                <el-menu-item index="1-2">功能二</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group title="功能组二">
                <el-menu-item index="1-3">功能三</el-menu-item>
              </el-menu-item-group>
            </el-sub-menu>
            <el-menu-item index="2" class="active-menu-item">
              <el-icon><icon-menu /></el-icon>
              <span>数据管理</span>
            </el-menu-item>
            <el-menu-item index="3">
              <el-icon><document /></el-icon>
              <span>报表中心</span>
            </el-menu-item>
            <el-menu-item index="4">
              <el-icon><setting /></el-icon>
              <span>系统设置</span>
            </el-menu-item>
          </el-menu>
        </el-aside>

        <!-- 主内容区 -->
        <el-main class="main-content">
          <!-- 面包屑导航 -->
          <el-breadcrumb separator="/" class="breadcrumb">
            <el-breadcrumb-item>首页</el-breadcrumb-item>
            <el-breadcrumb-item>数据管理</el-breadcrumb-item>
          </el-breadcrumb>

          <!-- 内容区域网格布局 -->
          <el-row :gutter="20">
            <el-col :span="12">
              <el-card class="form-card">
                <template #header>
                  <div class="card-header">
                    <span>信息</span>
                  </div>
                </template>
                <!-- 表单区域 -->
                <el-form :model="form" label-width="120px" class="form">
                  <el-form-item label="活动名称">
                    <el-input v-model="form.name" placeholder="请输入活动名称" />
                  </el-form-item>
                  <el-form-item label="活动区域">
                    <el-select v-model="form.region" placeholder="请选择活动区域" style="width: 100%">
                      <el-option label="区域一" value="shanghai" />
                      <el-option label="区域二" value="beijing" />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="活动时间">
                    <el-col :span="11">
                      <el-date-picker
                        v-model="form.date1"
                        type="date"
                        placeholder="选择日期"
                        style="width: 100%"
                      />
                    </el-col>
                    <el-col :span="2" class="text-center">
                      <span class="text-gray-500">-</span>
                    </el-col>
                    <el-col :span="11">
                      <el-time-picker
                        v-model="form.date2"
                        placeholder="选择时间"
                        style="width: 100%"
                      />
                    </el-col>
                  </el-form-item>
                </el-form>
              </el-card>
            </el-col>
            <el-col :span="12">
              <el-card class="form-card">
                <template #header>
                  <div class="card-header">
                    <span>详细信息</span>
                  </div>
                </template>
                <div class="form">
                  <el-form-item label="即时配送">
                    <el-switch v-model="form.delivery" />
                  </el-form-item>
                  <el-form-item label="活动性质">
                    <el-checkbox-group v-model="form.type">
                      <el-checkbox value="线上活动" name="type">线上</el-checkbox>
                      <el-checkbox value="促销活动" name="type">促销</el-checkbox>
                    </el-checkbox-group>
                  </el-form-item>
                  <el-form-item label="资源来源">
                    <el-radio-group v-model="form.resource">
                      <el-radio value="赞助">赞助</el-radio>
                      <el-radio value="场地">场地</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="活动形式">
                    <el-input v-model="form.desc" type="textarea" placeholder="请输入活动形式" />
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit">提交</el-button>
                    <el-button @click="onReset">重置</el-button>
                  </el-form-item>
                </div>
              </el-card>
            </el-col>
          </el-row>

          <!-- 下部三栏布局 -->
          <el-row :gutter="20" class="bottom-row">
            <el-col :span="8">
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <el-icon><data-line /></el-icon>
                    <span>数据统计</span>
                  </div>
                </template>
                <div class="stat-content">
                  <div class="stat-item">
                    <span class="stat-label">总用户数</span>
                    <span class="stat-value">1,234</span>
                  </div>
                  <div class="stat-item">
                    <span class="stat-label">今日访问</span>
                    <span class="stat-value">567</span>
                  </div>
                  <div class="stat-item">
                    <span class="stat-label">活跃用户</span>
                    <span class="stat-value">89</span>
                  </div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <el-icon><bell /></el-icon>
                    <span>最新动态</span>
                  </div>
                </template>
                <div class="news-content">
                  <div class="news-item">
                    <span class="news-time">10:30</span>
                    <span class="news-text">系统更新完成</span>
                  </div>
                  <div class="news-item">
                    <span class="news-time">09:15</span>
                    <span class="news-text">新用户注册</span>
                  </div>
                  <div class="news-item">
                    <span class="news-time">08:45</span>
                    <span class="news-text">数据备份成功</span>
                  </div>
                </div>
              </el-card>
            </el-col>
            <el-col :span="8">
              <el-card class="info-card">
                <template #header>
                  <div class="card-header">
                    <el-icon><message /></el-icon>
                    <span>系统消息</span>
                  </div>
                </template>
                <div class="message-content">
                  <div class="message-item">
                    <el-tag type="success" size="small">正常</el-tag>
                    <span>系统运行正常</span>
                  </div>
                  <div class="message-item">
                    <el-tag type="warning" size="small">警告</el-tag>
                    <span>存储空间不足</span>
                  </div>
                  <div class="message-item">
                    <el-tag type="info" size="small">信息</el-tag>
                    <span>定期维护提醒</span>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
  DataLine,
  Bell,
  Message,
} from '@element-plus/icons-vue'
import { reactive } from 'vue'

const form = reactive({
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
})

const onSubmit = () => {
  console.log('submit!', form)
}

const onReset = () => {
  Object.assign(form, {
    name: '',
    region: '',
    date1: '',
    date2: '',
    delivery: false,
    type: [],
    resource: '',
    desc: '',
  })
}
</script>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

#app {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-container {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.full-container {
  height: 100vh !important;
  width: 100vw !important;
  display: flex;
  flex-direction: column;
}

.header {
  height: 60px !important;
  padding: 0 !important;
  flex-shrink: 0;
  background-color: #545c64;
}

.main-container {
  height: calc(100vh - 60px) !important;
  width: 100% !important;
  display: flex;
  flex: 1;
}

.sidebar {
  width: 220px !important;
  height: 100% !important;
  background-color: #545c64;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  padding: 20px;
  background-color: #f5f5f5;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
}

.breadcrumb {
  margin-bottom: 20px;
}

.form {
  padding: 20px;
}

.bottom-row {
  margin-top: 20px;
}

.header-content {
  height: 60px;
  background-color: #545c64;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-title {
  color: white;
  font-size: 18px;
  font-weight: bold;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  color: white !important;
}

.header-btn:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.el-menu-vertical-demo {
  border-right: none;
  height: 100%;
}

/* 移除激活菜单项的特殊样式，让它保持默认样式 */
.active-menu-item {
  /* 移除所有特殊样式，使用默认的菜单项样式 */
}

.form-card {
  height: 100%;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.info-card {
  height: 100%;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.stat-content {
  padding: 10px 0;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-label {
  color: #666;
  font-size: 14px;
}

.stat-value {
  font-weight: bold;
  color: #409eff;
  font-size: 16px;
}

.news-content {
  padding: 10px 0;
}

.news-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.news-item:last-child {
  border-bottom: none;
}

.news-time {
  color: #999;
  font-size: 12px;
  margin-right: 10px;
  min-width: 40px;
}

.news-text {
  color: #333;
  font-size: 14px;
}

.message-content {
  padding: 10px 0;
}

.message-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.message-item:last-child {
  border-bottom: none;
}

.text-center {
  text-align: center;
}

.text-gray-500 {
  color: #999;
}

/* 菜单项悬停效果 */
.el-menu-item:hover {
  background-color: #434a50 !important;
}

.el-sub-menu .el-sub-menu__title:hover {
  background-color: #434a50 !important;
}

/* 确保所有容器占满空间 */
.el-container {
  height: 100% !important;
  width: 100% !important;
}

.el-row {
  margin-bottom: 20px;
}

.el-row:last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}
</style>